#ifndef CALCULATE_LOWERCOMPUTER_DATA_H
#define CALCULATE_LOWERCOMPUTER_DATA_H

#include <QObject>
#include <QTimer>

/**
 * YZG-1：制动缸压力360；YZ-1：制动压力：420

1,大闸缓解、制动，小闸制动，紧急制动、辅助制动，会使用总风缸
2,大闸制动(大闸制动，只有大闸缓解，小闸缓解/下压无效；)
3,小闸制动（小闸制动，只有大闸下压，小闸缓解，大闸缓解无效）
4,紧急制动的制动压力，只有大闸的缓解位可以缓解
5,辅助制动的制动压力，只有辅助制动关闭可以缓解
6，制动缸里，存在紧急制动，大闸压力，小闸压力时，先缓解紧急制动压力，再缓解大闸压力，最后缓解小闸压力

问题：
*/

class CalculateLowerComputerData : public QObject
{
    Q_OBJECT
public:
   CalculateLowerComputerData();
   // explicit CalculateLowerComputerData(QObject *parent = nullptr);

private:
   QTimer *m_timer;
   //刷新时间（毫秒）
   int m_refreshTime = 20;
   double m_timeUnit = 1000.0/m_refreshTime;

private:
    //总风杠
    double m_totalWindCylinderPressure = 0.0;
    //列车管
    double m_trainPipePressure= 0.0;
    //均风缸
    double m_equalizeCylinderPressure = 0.0;
    //制动缸
    double m_brakeCylinderPressure = 0.0;

    //用于紧急制动时，大闸位于缓解位或运转位，总风缸压力初始泄露速度
    double m_totalWindCylinderPressureDifference = 2;

    //制动缸压力平时的最大值（如果紧急制动后，会变为430）
    double m_maxBrakeCylinderPressure = 360.0;

    //如果制动缸压力超过360后（内还存有小闸压力），使用大闸缓解后，被减的制动缸压力
    double m_maxBrakeCylinderPressureSaveMax = 0.0;


    //是否给总分杠压力冲风，低于660时，为true
    bool m_isImpulsetotalWindCylinderPressure = true;

    //加速度
    //启动车后
    //总风缸压力
    double m_totalWindCylinderPressureAcceleration_1 = 720.0/(160.0*m_timeUnit);

    //总风杠减少压力值
    double m_totalWindCylinderPressureDecreasevalue = 0;

    ////大闸
    ///制动位
    //列车管（降低）
    double m_trainPipePressureAcceleration_2 = 500.0/(12.0*m_timeUnit);
    //均衡风缸（降低）
    double m_equalizeCylinderPressureAcceleration_2 = 500.0/(11.5*m_timeUnit);

    ///缓解位
    //列车管（降低）
    double m_trainPipePressureAcceleration_10 = 500.0/(4.0*m_timeUnit);
    //均衡风缸（降低）
    //0-250kPa
    double m_equalizeCylinderPressureAcceleration_10 = 500.0/(1.2*m_timeUnit);
    //250-500
    double m_equalizeCylinderPressureAcceleration_11 = 500.0/(6.6*m_timeUnit);

    ///大闸制动
    //制动缸压力（处于制动位）
    double m_brakeCylinderPressureAcceleration_3 = 360.0/(2.0*m_timeUnit);

    ///大闸缓解
    //大闸：制动缸（降低）；
    double m_brakeCylinderPressureAcceleration_2 = 360.0/(4.0*m_timeUnit);


    //大闸下压位【制动缸减压力】;
    //小闸制动，大闸只有下压，才可以减少制动，大闸缓解不可以
     double m_brakeCylinderPressureAcceleration_4 = 360.0/(1.25*m_timeUnit);

     //大、小闸
    ///保压位
    double m_trainPipePressureAcceleration_9 = 360.0/(9800.0*m_timeUnit);
    double m_brakeCylinderPressureAcceleration_9 = 360.0/(9800.0*m_timeUnit);

    ////小闸
    ///下压位————制动缸（减少）
    double m_brakeCylinderPressureAcceleration_5 = 360.0/(1.9*m_timeUnit);
    //小闸：制动缸（上升）
    double m_brakeCylinderPressureAcceleration_10 = 360.0/(1.7*m_timeUnit);

    //紧急制动
    //列车管（降压）
    double m_trainPipePressureAcceleration_6 = 500.0/(1.5*m_timeUnit);
    //制动缸（升压）
    double m_brakeCylinderPressureAcceleration_6 = 420.0/(1.02*m_timeUnit);
    //总风缸（减压）
    double m_brakeCylinderPressureAcceleration_8 = 360.0/(45*m_timeUnit);

    //辅助制动（制动缸压力下降）
    double m_brakeCylinderPressureAcceleration_7 = 360.0/(1.16*m_timeUnit);

    ///
    //小闸冲的制动压力改变值
    double m_smallGateBrakeCylinderPressure = 0.0;

    //大闸冲的制动压力值改变值
    double m_bigGateBrakeCylinderPressure = 0.0;

    //紧急制动冲的压力值改变值
    double m_emergencyBrakingBrakeCylinderPressure = 0.0;

    //辅助制动缸制动缸压力
    double m_auxiliaryBrakingBrakeCylinderPressure = 0.0;

    //保存制动压力，减少前的变化值
    double m_smallGateBrakeCylinderPressureSaveChangeValue = 0.0;
    double m_bigGateBrakeCylinderPressureSaveChangeValue = 0.0;
    double m_emergencyBrakingBrakeCylinderPressureSaveChangeValue = 0.0;
    double m_auxiliaryBrakingBrakeCylinderPressureSaveChangeValue = 0.0;

public slots:
    //开始计算
    void stopCalculateWork();
    //关闭计算
    void startCalculateWork();

signals:
    void refreshShow();
};

#endif // CALCULATE_LOWERCOMPUTER_DATA_H
